<script>
import {
  defineComponent,
  reactive,
  toRefs
} from 'vue'

export default defineComponent({
  name: 'StandardPlayer',
  props: {
    height: {
      type: [Number, String],
      default: '400px'
    },
    width: {
      type: [Number, String],
      default: '600px'
    },
    // 包含录制
    hasRecording: {
      type: Boolean,
      default: true
    },
    // 包含截图
    hasPrint: {
      type: Boolean,
      default: true
    },
    // 包含停止
    hasStop: {
      type: Boolean,
      default: true
    },
    hasSettings: {
      type: Boolean,
      default: true
    },
    hasSize: {
      type: Boolean,
      default: true
    }
  },
  setup() {
    const state = reactive({})

    return {
      ...toRefs(state)
    }
  }
})
</script>

<template>
  <div class="component-standard-player-container"
       :style="{ width: `${typeof width === 'string' ? width : width + 'px'}`, height: `${typeof height === 'string' ? height : height + 'px'}` }">
    <div class="player-slot">
      <slot />
    </div>
    <div class="control-bar">
      <div class="size">
        <span>宽度:0px</span>
        <span>高度:0px</span>
      </div>
      <div class="button stop" v-if="hasStop" />
      <div class="button print-screen" v-if="hasPrint" />
      <div class="button start" v-if="hasRecording" />
      <div class="button end" v-if="hasRecording" />
      <div class="button settings" v-if="hasSettings" />
    </div>
  </div>
</template>

<style lang="scss">
.component-standard-player-container {
  background-color: #343434;
  border: 1px solid #D5D5D5;
  .player-slot {
    height: calc(100% - 56px);
  }
  .control-bar {
    height: 56px;
    background-color: #f2f2f2;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 12px;
    user-select: none;
    cursor: pointer;

    .size {
      margin-right: 12px;

      span:last-child {
        margin-left: 12px;
      }
    }

    .button {
      height: 32px;
      background-size: 80%;
      background-repeat: no-repeat;
      background-position: center center;
      margin-right: 12px;

      &:last-child {
        margin: 0;
      }

      &.start {
        width: 43px;
        background-image: url('../assets/components/standard-player--start.png');
      }

      &.end {
        width: 45px;
        background-image: url('../assets/components/standard-player--end.png');
      }

      &.print-screen {
        width: 39px;
        background-image: url('../assets/components/standard-player--print-screen.png');
      }

      &.stop {
        width: 32px;
        background-image: url('../assets/components/standard-player--stop.png');
      }

      &.settings {
        width: 32px;
        background-image: url('../assets/components/standard-player--settings.png');
      }
    }
  }
}
</style>
